package com.nstar.orderexpress.view
{
	import mx.containers.VBox;
	import mx.controls.Button;
	import mx.events.FlexEvent;
	import flash.events.MouseEvent;
	import com.nstar.orderexpress.model.Model;
	import com.nstar.base.util.Logger;
	import mx.collections.ArrayCollection;
	import mx.containers.HBox;
	import mx.controls.Label;
	import mx.containers.Canvas;
	import mx.controls.RadioButtonGroup;
	import mx.events.ItemClickEvent;
	import com.nstar.base.controls.HintTextInput;
	import com.nstar.orderexpress.control.QueryEvent;
	import com.nstar.orderexpress.vo.QueryVO;
	import com.adobe.cairngorm.control.CairngormEventDispatcher;

	public class SearchClass extends VBox
	{
		public var btnSearch:Button;
		public var txtCount:Label;
		public var rbgSearchType:RadioButtonGroup;
		public var htiSearch:HintTextInput;
		
		private var model:Model = Model.getInstance();
		private var logger:Logger = Logger.getInstance();
		
		public function SearchClass()
		{
			//TODO: implement function
			super();
			this.addEventListener(FlexEvent.CREATION_COMPLETE,init);
		}
		
		private function init(event:FlexEvent):void{
			btnSearch.addEventListener(MouseEvent.CLICK,searchHandler);
			rbgSearchType.addEventListener(ItemClickEvent.ITEM_CLICK,itemclickHandler);
		}
		
		private function itemclickHandler(event:ItemClickEvent):void{
			switch (event.index){
				case 0:
					htiSearch.defaultText = "请输入要搜索的菜名";
					break;
				case 1:
					htiSearch.defaultText = "请输入您要搜索的餐馆";
					break;
				case 2:
					htiSearch.defaultText = "请输入您所在的位置";
					break;
			}
			htiSearch.setDefaultText(null);
		}
		
		private function searchHandler(event:MouseEvent):void{
			/*
			var dp:ArrayCollection = new ArrayCollection();
			for(var i:int = 1;i<20;i++){
				var item:Object = new Object();
				item.title = "我的菜单 "+i;
				item.price = 10 * Math.random();
				item.menuId = i;
				dp.addItem(item);
			}
			txtCount.text = "共 "+dp.length+" 条记录";
			model.mainApp.mainView.filterView.atlMenuList.dataProvider = dp;
			*/
			var queryEvent:QueryEvent = new QueryEvent(new QueryVO);
			CairngormEventDispatcher.getInstance().dispatchEvent(queryEvent);
			model.mainApp.mainView.vsMenus.selectedIndex = 0;
		}
		
		
		
	}
}